<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:p="http://primefaces.org/ui">

<h:head>

</h:head>
<h:body>
	<ui:include src="menu.xhtml" />

	<h:form id="formCotacao" rendered="true">

		<p:messages for="formLista" autoUpdate="true" />
		<p:panel id="display" header="Cotação Voo" style="margin-top:10px;">
			<div align="center">
				<h:panelGrid columns="2" columnClasses="colunaEsquerda,colunaDireita">

					<p:outputLabel for="txtOrigemTrecho" value="Origem:" />
					<p:selectOneMenu id="txtOrigemTrecho" value="#{vendaVooMB.cotacao.vooIda.origemVoo}">
						<f:selectItem itemLabel="Selecione..." />
						<f:selectItems value="#{vendaVooMB.listaAeroportoBean}" var="aeroporto" itemLabel="#{aeroporto.siglaAeroporto} - #{aeroporto.ufAeroporto} - #{aeroporto.cidadeAeroporto}" itemValue="#{aeroporto.siglaAeroporto}" />
					</p:selectOneMenu>

					<p:outputLabel for="txtDestinoTrecho" value="Destino:" />
					<p:selectOneMenu id="txtDestinoTrecho" value="#{vendaVooMB.cotacao.vooIda.destinoVo}">
						<f:selectItem itemLabel="Selecione..." />
						<f:selectItems value="#{vendaVooMB.listaAeroportoBean}" var="aeroporto" itemLabel="#{aeroporto.siglaAeroporto} - #{aeroporto.ufAeroporto} - #{aeroporto.cidadeAeroporto}" itemValue="#{aeroporto.siglaAeroporto}" />
					</p:selectOneMenu>

					<h:outputLabel for="txtDataDecolagem" value="Data Ida: " styleClass="createStaticField" />
					<p:calendar timeZone="#{initParam.timezone}" value="#{vendaVooMB.cotacao.vooIda.dataPrevistaDecolagem}" id="txtDataDecolagem" pattern="dd/MM/yyyy" size="15" maxlength="15" />

					<h:outputLabel for="txtQtdPrimeiraClasse" value="Passageiros Primeira Classe: " styleClass="createStaticField" />
					<p:inputText id="txtQtdPrimeiraClasse" styleClass="inputText" size="3" maxlength="3" value="#{vendaVooMB.cotacao.qtdPassageirosPrimeiraClasse}">
						<f:convertNumber integerOnly="true" />
					</p:inputText>

					<h:outputLabel for="txtQtdClasseEconomica" value="Passageiros Classe Economica: " styleClass="createStaticField" />
					<p:inputText id="txtQtdClasseEconomica" styleClass="inputText" size="3" maxlength="3" value="#{vendaVooMB.cotacao.qtdPassageirosClasseEconomica}">
						<f:convertNumber integerOnly="true" />
					</p:inputText>

				</h:panelGrid>
			</div>
			<center>
				<p:commandButton value="Pesquisar" styleClass="button" update="lista" id="listagemBtPesquisar" action="#{vendaVooMB.list}" />
				<p:commandButton styleClass="button" value="Limpar" update="@form" id="btLimpar" action="#{vendaVooMB.limparFormCotacao}" />
			</center>



			<p:separator style="width:100%" />

			<p:dataTable id="lista" var="cotacao" paginator="true" rows="20" value="#{vendaVooMB.listaItemCotacao}">

				<p:column style="text-align:center; width: 30%" rendered="true">
					<f:facet name="header">Código Voo</f:facet>
					<h:outputText value="#{cotacao.vooIda.codigoVoo}"></h:outputText>
				</p:column>


				<p:column style="text-align:center; width: 15%" rendered="true">
					<f:facet name="header">Origem</f:facet>
					<h:outputText value="#{cotacao.vooIda.origemVoo}" />
				</p:column>


				<p:column style="text-align:center; width: 15%" rendered="true">
					<f:facet name="header">Destino</f:facet>
					<h:outputText value="#{cotacao.vooIda.destinoVo}" />
				</p:column>


				<p:column style="text-align:center; width: 15%" rendered="true">
					<f:facet name="header">Dt Decolagem</f:facet>
					<h:outputText value="#{cotacao.vooIda.dataPrevistaDecolagem}">
						<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="#{initParam.timezone}" />
					</h:outputText>
				</p:column>

				<p:column style="text-align:center; width:7%" rendered="true">
					<f:facet name="header">Valor Pacote</f:facet>
					<h:outputText value="#{cotacao.valorCotacao}" />
				</p:column>

				<p:column style="text-align:center; width: 5%" rendered="#{!loginMB.usuarioLogado}">
					<p:commandLink id="linkReservar" onclick="popupLogin.show();" title="[Não Logado]">
						<p:graphicImage width="20px" url="images/reservar.png" title="Reservar" />
					</p:commandLink>
				</p:column>

				<p:column style="text-align:center; width: 5%" rendered="#{loginMB.usuarioLogado}">
					<p:commandLink id="linkReservar2" action="#{vendaVooMB.showReserva}">
						<p:graphicImage width="20px" url="images/reservar.png" title="Reservar" />
						<f:setPropertyActionListener target="#{vendaVooMB.cotacao}" value="#{cotacao}" />
					</p:commandLink>
				</p:column>

			</p:dataTable>
		</p:panel>
	</h:form>
</h:body>
</html>
